package com.phenix.network

import com.phenix.network.base.BaseNetworkApi
import com.phenix.network.base.Envelope
import com.phenix.network.environment.IEnvironment
import com.phenix.network.response.MoshiResultTypeAdapterFactory
import okhttp3.Interceptor

object WanAndroidOpenApi : BaseNetworkApi(object : IEnvironment {
    override fun getBaseUrl(isDevelop: Boolean): String {
        return if (isDevelop) "https://www.wanandroid.com" else "https://www.wanandroid.com123"
    }

}) {
    override fun getInterceptor(): Interceptor? {
        return null
    }

    override fun getErrorEnvelope(): Envelope {
        return object : Envelope{
            override fun getStatusCodeKey(): String {
                return "errorCode"
            }

            override fun getErrorMessageKey(): String {
                return "errorMsg"
            }
        }
    }

    override fun getEnvelopeHandler(): Envelope {
        return object : Envelope {
            override fun getStatusCodeKey(): String {
                return "errorCode"
            }

            override fun getErrorMessageKey(): String {
                return "errorMsg"
            }

            override fun getDataKey(): String {
                return "data"
            }

            override fun doesStatusCodeIndicateSuccess(statusCode: Int): Boolean {
                return statusCode == 0
            }

        }
    }
}